<?php
require_once dirname(__DIR__)."/login_filter.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\cls\tom\Tools;
use app\model\Users;
//1.接收参数
if(empty($_REQUEST['uuid'])){
    Response::output(-1,"缺少参数");
}
$other_uuid=$_REQUEST['uuid'];//他人uuid
$uuid=$Auth['uuid'];//我的uuid

//2.实例化redis和数据库
$db = SysResource::getDB(false);
$Users = new Users($db);
$redis = SysResource::getRedis();
$uid=sprintf("%d",crc32($uuid));//自己的uuid
$key1=REDIS_PREFIX."follow_".$uid;//关注
$key2=REDIS_PREFIX."is_follow_".$uid;//被关注（粉丝）

//3.先去redis里查询我的关注
$da4=[];
$da6=[];
$r1=$redis->hKeys($key1);//从redis里获取我的关注
$r1="";
if(empty($r1)){
    $da2=$Users->follows($uuid);//从数据库里获取我的关注
    if(!empty($da2)){
        foreach($da2 as $k=>$v){
            $da4[]=$v['other_uuid'];
        }
    }
}else{
    $da4=$r1;
}

//4.先去redis里查询我的粉丝
$r2=$redis->hKeys($key2);//从redis里获取我的关注
if(empty($r2)){
    $da1=$Users->is_follows($uuid);//被关注
    if(!empty($da1)){
        foreach($da1 as $kkk=>$vvv){
            $da6[]=$v['my_uuid'];//他人关注
        }
    }
}else{
    $da6=$r2;
}
//5.他人主页信息
$da=$Users->my_home($other_uuid,2);
if(in_array($other_uuid,$da4) && in_array($other_uuid,$da6)){
    //互相关注
    $da['guanzhu']=3;
}else if(in_array($other_uuid,$da4)){
    //已关注
    $da['guanzhu']=2;
}else{
    //未关注
    $da['guanzhu']=1;
}
if(empty($da['test_user_autograph'])){
    $da['test_user_autograph']="";
}
//6.获取他人作品个数
$count_material=$Users->count_material($other_uuid,2);
$da['count_material']=count($count_material);
Response::output(0,"查询成功",$da);





